import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.Scanner;

public class NGuessNumber {

    public List generateAnswer() {
        List li = new ArrayList();
        Random rr = new Random();
        while (li.size() < 4) {
            int num = rr.nextInt(10);
            if (!li.contains(num)) {
                li.add(num);
            } else {
                num = rr.nextInt(10);
            }
        }
        return li;
    }

    public int caishuzi(List list) {
        Scanner ss = new Scanner(System.in);
        System.out.println("请输入数字");
        String srnum = ss.next();
        String a[] = srnum.split("");
        ArrayList b = new ArrayList();
        for(int i=0;i<a.length;i++){
            b.add(Integer.valueOf(a[i]));
        }
        int A = 0;
        int B = 0;
        for(int j=0;j<b.size();j++){
            if(list.get(j)==b.get(j)) {
                A++;
            }
            if(list.contains(b.get(j))) {
                B++;
            }
        }
        B = B-A;
        if(A!=4) {
            System.out.println("A"+A+"B"+B);
        }
        return A;
    }

    public static void main(String[] args) {
        NGuessNumber cc = new NGuessNumber();
        List list = cc.generateAnswer();
        while(true) {
            int flag = cc.caishuzi(list);
            if(flag ==4){
                System.out.println("恭喜");
                break;
            }
        }
    }
}
